﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using AspNetCs.Model;
using AspNetCs.IDAL;
using AspNetCs.DALFactory;
using AspNetCs.SQLServerDAL;
using AspNetCs.Common;

namespace AspNetCs.Bll
{
    public class AncestralHallBBSBLL
    {
        private IAncestralHallBBS dal = Conn.CreateAncestralHallBBS();

        /// <summary>
        /// 添加宗祠论坛
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(AncestralHallBBS_Model model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 修改宗祠论坛
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Update(AncestralHallBBS_Model model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除宗祠论坛(物理删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delete(int id)
        {
            return dal.Delete(id);
        }

        /// <summary>
        /// 删除宗祠论坛(逻辑删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Hidden(int id)
        {
            return dal.Hidden(id);
        }

        /// <summary>
        /// 通过宗祠编号查询宗祠论坛
        /// </summary>
        /// <param name="CreateId">宗祠编号</param>
        /// <param name="RequeryItems">查询的字段</param>
        /// <param name="IsDel">是否查询的被删除的信息 0:没有删除的 1:删除了的 2:所有的</param>
        /// <returns></returns>
        public DataTable getAncestralHallBBSByAncestralHallId(int id, string RequeryItems, int IsDel)
        {
            return dal.getAncestralHallBBSByAncestralHallId(id,RequeryItems,0);
        }


        /// <summary>
        /// 修改宗祠论坛顶部
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateTopContent(AncestralHallBBS_Model model)
        {
            return dal.UpdateTopContent(model);
        }


        /// <summary>
        /// 修改宗祠论坛底部
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateBottomContent(AncestralHallBBS_Model model)
        {
            return dal.UpdateBottomContent(model);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public DataTable GetDataTable(string filter)
        {
            return dal.GetDataTable(filter);
        }

        public AncestralHallBBS_Model GetModel(string filter)
        {
            AncestralHallBBS_Model model = new AncestralHallBBS_Model();
            DataTable dataTable = new DataTable();
            dataTable = GetDataTable(filter);
            if(dataTable.Rows.Count>0)
            {
                model.AncestralHallId = StringHelper.isNumber_int(dataTable.Rows[0]["AncestralHallId"].ToString());
                model.BBSAnnouce = dataTable.Rows[0]["BBSAnnouce"].ToString();
                model.BBSBottom = dataTable.Rows[0]["BBSBottom"].ToString();
                model.BBSTop = dataTable.Rows[0]["BBSTop"].ToString();
                model.CreateTime = StringHelper.isDatetime(dataTable.Rows[0]["CreateTime"].ToString());
                model.Id = StringHelper.isNumber_int(dataTable.Rows[0]["Id"].ToString());
                model.IsCheck = StringHelper.isNumber_int(dataTable.Rows[0]["IsCheck"].ToString());
                model.IsDel = StringHelper.isNumber_int(dataTable.Rows[0]["IsDel"].ToString());
            }
            return model;
        }
    }
}
